ubuntu apt-get常见错误

错误1

通过终端安装程序sudo apt-get install xxx时出错:

1
2
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it

出现这个问题可能是有另外一个程序正在运行,导致资源被锁不可用。而导致资源被锁的原因可能是上次运行安装或更新时没有正常完成,进而出现此状况,解决的办法其实很简单:

在终端中敲入以下两句

1
2
3
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a

错误2

出现错误:

1
The following packages have unmet dependencies:

解决方法:

1
sudo apt-get install -f

错误3

出现错误:

1
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable

解决方法:

1
2
sudo lsof /var/cache/debconf/config.dat
sudo kill -9

错误4

出现错误

1
2
3
Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/

解决方法

1
sudo rm /var/lib/apt/lists/lock

错误5

出现错误The list of sources could not be read.例如下面:

1
2
3
ubuntu@ubuntu-ubuntu:~$ sudo apt-get update
E: Malformed entry 65 in list file /etc/apt/sources.list (Component)
E: The list of sources could not be read.

则打开终端输入:

1
sudo gedit /etc/apt/sources.list

将有问题的源删去即可

错误5

出现错误:

1
error: parsing file '/var/lib/dpkg/updates/0002' near line 0:newline in field name `#padding':

解决方法:

1
2
3
sudo rm /var/lib/dpkg/updates/*
sudo apt-get update
sudo apt-get upgrade

错误6

ubuntu安装软件has install-snap change in progress错误:

今天在ubuntu软件商店安装idea报错:

1
cannot install "intellij-idea-community": snap "intellij-idea-community"  has "install-snap" change in progress

其实就是软件之前安装了一次,只是没安装完。解决方案

1
snap changes

可以看到ID=5是我之前安装失败的。
现在我们终止它

1
sudo snap abort 5

好了,可以重新安装了

------ 本文结束------
坚持原创技术分享,您的支持将鼓励我继续创作!

欢迎关注我的其它发布渠道